import request from "@/utils/request.ts"

// 获取所有角色
export const getAllSystemRoles = (data) => {
    return request({
        method: "get",
        url: `/admin/acl/role/${data.page}/${data.limit}`,
        params: {
            roleName: data.roleName
        }
    })
}

// 新增角色
export const addRole = (data) => {
    return request({
        method: "post",
        url: `/admin/acl/role/save`,
        data
    })
}

// 修改用户
export const updateRole = (data) => {
    return request({
        method: "put",
        url: `/admin/acl/role/update`,
        data
    })
}

// 根据角色获取菜单等信息
export const getMenuByRoleId = (id) => {
    return request({
        method: "get",
        url: `/admin/acl/permission/toAssign/${id}`,
    })
}

// 修改角色的菜单权限
export const updateTheRoleMenuPermission = (data) => {
    console.log(data)
    return request({
        method: "post",
        url: `/admin/acl/permission/doAssign?roleId=${data.roleId}&permissionId=${data.permissionId}`,
    })
}

// 删除角色
export const deleteRole = (id) => {
    return request({
        method: "delete",
        url: `/admin/acl/role/remove/${id}`
    })
}